package telnetserver;

public class Snake {
    private Telnet telnet;
    private Object ret;
    
    public Snake(Telnet t, Object r) {
        telnet = t;
        ret = r;
    }
    
    public void addUser(User u) {
        u.setCanWrite(false);
        u.setCanPress(true);
        
        u.clear();
        u.send();
        u.prepare(1, 2, 2, "Snake, the first game - beta beta!");
        String[] buttons = { "BACK", "START" };
        u.setButtons(buttons, null);
        u.fixButtonsXY(2, 4, 1);
        u.drawButtons();
    }
    
     public void read(User u, String s) {
         int btn = u.getButton()[1];
         if (btn == 0) telnet.changeMode(u, ret);
         else {
             SnakeGame game = new SnakeGame(telnet, this, u);
             telnet.changeMode(u, game);
             game.start();
         }
     }
}
